package com.edu.exam.enums.curriculum;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 课程风险级别枚举
 *
 * <p>定义课程管理中的风险级别。</p>
 *
 * @author System
 * @version 1.0.0
 * @since 2025-11-17
 */
public enum RiskLevel implements BaseEnum {

    LOW("LOW", "低风险"),
    MEDIUM("MEDIUM", "中风险"),
    HIGH("HIGH", "高风险"),
    CRITICAL("CRITICAL", "关键风险");

    private final String code;
    private final String description;

    RiskLevel(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static RiskLevel fromCode(String code) {
        for (RiskLevel level : values()) {
            if (level.getCode().equals(code)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Unknown risk level code: " + code);
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}
